---
sidebar_position: 4
title: Guide - Query Params
sidebar_label: Query Params
---

# Query Params

---

### Request query parameters

The use of query params is based on built-in parser. We can freely change its options and format to match our needs.

---

### Setting query params

You can set query params by using the `setQueryParams` method on request. It's type can be configured on request
creation.

```ts
type QueryParamsType = {
  search: string;
  sort: string;
};

const getUsers = client.createRequest<Response, void, void, QueryParamsType>()({ endpoint: "/users" });

// Setting the query params

const request = getUsers.setQueryParams({ search: "John", sort: "age" });
console.log(request.endpoint); // Output: "/users?search=John&sort=age"
```

```ts
const getUsers = client.createRequest<Response, void, void, string>()({ endpoint: "/users" });

const request = getUsers.setQueryParams("search=John&sort=age");
console.log(request.endpoint); // Output: "/users?search=John&sort=age"
```

### Custom query params format

We can setup custom config with instructions how to stringify the values. It can be setup on the client with
`setQueryParamsConfig` method.

#### Available options:

{/* (@import HyperFetch QueryStringifyOptionsType type=returns) */}

---
